//
//  FileListController.m
//  EducationAdminClient
//
//  Created by 孙添凤 on 17/3/22.
//  Copyright © 2017年 周佳兴. All rights reserved.
//

#import "FileListController.h"
#import "Masonry.h"
#import "SeeingThePDFViewController.h"

@interface FileListController ()

@end

@implementation FileListController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.tbView =[[UITableView alloc]init];
    [self.view addSubview:self.tbView];
    UIEdgeInsets edge = UIEdgeInsetsMake(0, 0, 0, 0);
    [self.tbView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.view).insets(edge);
    }];
    self.tbView.delegate = self;
    self.tbView.dataSource = self;
    [self createLeftNavBar];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _nameArr.count;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *indentifier =@"dddd";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indentifier];
    if(cell==nil){
        cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:indentifier];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    
    cell.textLabel.text =[_nameArr objectAtIndex:indexPath.row];

    return cell;
                      
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (_fileMongoArr.count>indexPath.row+1) {
        SeeingThePDFViewController *seevc =[[SeeingThePDFViewController alloc]init];
        seevc.fileMongoArr = [[NSMutableArray alloc]initWithObjects:_fileMongoArr[indexPath.row],nil];
        
        
        seevc.mongodbIDArr = _mongodbIDArr;
        seevc.nameArr = _nameArr;
        [self.navigationController pushViewController:seevc animated:YES];

    }else{
        [self showLabelWithText:@"附件数据不健全无法显示"];
    }

}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
